<?php	
class Obj_SpecialOffer {
	
	protected static $t;
	
	public static function init() {
		self::$t = new Obj_DBTable_SpecialOffer();
	}
	
	public static function getPaginatedSpecialOffers($page, $active_only = false) {
		return self::$t->getPaginatedSpecialOffers($page, $active_only);
	}
	
	public static function getAllSpecialOffers($active_only = false) {
		$ar_ = self::$t->getAllSpecialOffers($active_only);
		$ar = array();
		foreach ($ar_ as $k => $v) {
			$ar[$v['ID']] = $v;
		}
		return $ar;
	}
	
	public static function getSitemapOffers() {
		return self::$t->getSitemapOffers();
	}
	
	public static function saveSpecialOffer($arData, $id) {
		if ((int)$id == (int)0) {
			return self::$t->insert($arData);
		}
		else self::$t->update($arData, 'ID = '.intval($id));
		return intval($id);
	}
	
	public static function getSpecialOffer($id, $activeOnly = false) {
		return self::$t->getSpecialOffer($id, $activeOnly);
	}
		
	public static function delSpecialOffer($id){
		return self::$t->delete('ID = '.intval($id));
	}
	
}Obj_SpecialOffer::init();

